<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>货品选择列表</title>
</head>
<link rel="stylesheet" type="text/css" href="/wms/js/plugins/jquery-easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/wms/js/plugins/jquery-easyui/themes/icon.css">
<script type="text/javascript" src="/wms/js/plugins/jquery-easyui/jquery.min.js"></script>
<script type="text/javascript" src="/wms/js/plugins/jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/wms/js/plugins/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/wms/js/plugins/fancybox/jquery.fancybox.js?v=2.1.5"></script>
<link rel="stylesheet" type="text/css" href="/wms/js/plugins/fancybox/jquery.fancybox.css?v=2.1.5" media="screen" />
<script type="text/javascript" src="/wms/js/common/common.js"></script>
<script type="text/javascript" src="/wms/js/common/selectProductList.js"></script>
<%@include file="/WEB-INF/views/common/page.jsp" %>
<script type="text/javascript">
/*选择货品*/
function selectProduct(btn) {
	var product = $(btn).data("product");
	var price;
	parent.$("#productDialog").dialog('close');
	parent.tr.find("[tag=pid]").val(product.id);
	parent.tr.find("[tag=name]").val(product.name);
	parent.tr.find("[tag=brandName]").text(product.brandName);
	if (parent.tr.find("[tag=costPrice]").length > 0) {
		parent.tr.find("[tag=costPrice]").val(product.costPrice);
		price = parseFloat(product.costPrice);
	} else {
		parent.tr.find("[tag=salePrice]").val(product.salePrice);
		price = parseFloat(product.salePrice);
	}
	parent.tr.find("[tag=number]").val("1");
	var number = parseFloat("1");
	if (price && number) {
		var amount = (price * number).toFixed(2);
		parent.tr.find("[tag=amount]").text(amount);
	}
}
</script>
<body class="easyui-layout">
	<div data-options="region:'north',border:false" style="height: 10%">
		<form id="queryForm" method="post" action="/wms/product_selectProductList.action" style="margin-top: 15px">
			<s:hidden name="qo.currentPage"/>
			<s:hidden name="qo.pageSize"/>
			关键字&nbsp;<s:textfield name="qo.keyword" />&nbsp;
			 所属品牌&nbsp;<s:select name="qo.brandId" list="#brands" listKey="id" listValue="name" headerKey="-1" headerValue="全部"></s:select>&nbsp;
			<a class="easyui-linkbutton" data-options="text:'查询',iconCls:'icon-search'" onclick="query()"></a>
		</form>
	</div>
	<div data-options="region:'south',border: false" style="height: 90%">
		<table id="table_datagrid">
			<thead>
				<tr>
					<th data-options="field:'id',align:'center'">编号</th>
					<th data-options="field:'image',width:1,align:'center'">货品图片</th>
					<th data-options="field:'name',width:1,align:'center'">货品名称</th>
					<th data-options="field:'sn',width:1,align:'center'">货品编码</th>
					<th data-options="field:'brand.name',width:1,align:'center'">所属品牌</th>
					<th data-options="field:'costPrice',width:1,align:'center'">成本价</th>
					<th data-options="field:'salePrice',width:1,align:'center'">销售价</th>
					<th data-options="field:'select',width:1,align:'center'"></th>
				</tr>
			</thead>
			<tbody>
				<s:iterator value="#objs">
					<tr>
						<td><s:property value="id" /></td>
						<td><a class="fancybox" href="<s:property value='imagePath'/>" title="<s:property value='name'/>"><img src="<s:property value='smallImagePath'/>" alt="暂无图片" /></a></td>
						<td><s:property value="name" /></td>
						<td><s:property value="sn" /></td>
						<td><s:property value="%{brand == null ? '暂无品牌' : brand.name}" /></td>
						<td><s:property value="costPrice" /></td>
						<td><s:property value="salePrice" /></td>
						<td><a class="easyui-linkbutton" data-options="text:'选择 此商品'" data-product="<s:property value='productJson'/>" onclick="selectProduct(this)"></a></td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
	</div>
</body>
</html>
